package datamodels;

import java.util.ArrayList;
import java.util.List;

/**
 * Design: Thank to GROUP 5
 * A User class. Containing its role, name.  
 * 
 * @author Alan Meaker
 * @version 11.15.2011
 */
public class User {
	/**
	 * the role of this user.
	 */
	private Role my_role;
	/**
	 * the name of this user.
	 */
	private String my_name;
	/** a list of role a user can be. */
	private List<Role> my_role_list;
	/** a list of manuscripts to review if they are a Reviewer*/
	private List<Manuscript> my_manuscripts_to_review_list = new ArrayList<Manuscript>();
	/**
	 * constructor.
	 */
	public User() {
		//TODO
	}
	/**
	 * constructor.
	 * @param the_name user's name.
	 */
	public User(String the_name) {
		my_name = the_name;
		my_role_list = new ArrayList<Role>();
	}
	public List<Manuscript> getManuscriptsToReviewList()
	{
		return my_manuscripts_to_review_list;
	}
	public void addManuscriptToReviewToList(Manuscript the_manuscript)
	{
		if (my_manuscripts_to_review_list == null)
		{
			my_manuscripts_to_review_list = new ArrayList<Manuscript>();
		}
		if (the_manuscript == null)
		{
			System.out.println("What the heck!");
		}
		my_manuscripts_to_review_list.add(the_manuscript);
	}
	/** get the roles of the user */
	public List<Role> getRoles() {
		return my_role_list;
	}
	/** add a role to the user*/
	public void addRole(Role the_role)
	{
		my_role_list.add(the_role);
	}
	/**
	 * precondition: role != NULL
	 * @param the_role the role we want to set to this user.
	 * postcondition: user.role = role.
	 */
	public void setCurrentRole(Role the_role) {
		my_role = the_role;
	}
	/**
	 * precondition: my_role ! = NULL. 
	 * 
	 * @return the current role of the user.
	 */
	public Role getCurrentRole() {
		return my_role;
	}
	/**
	 * precondition: my_name != NULL 
	 * 
	 * @return the name of the user.
	 */
	public String getName() {
		return my_name;
	}
	public boolean equals(User the_user)
	{
		boolean same = false;
		int correct = 0;
		if (my_name.equals(the_user.getName()))
		{
			correct++;
		}
		if (my_role == the_user.getCurrentRole())
		{
			correct++;
		}
		if (correct == 2)
		{
			same = true;
		}
		return same;
	}
}